<?
	class Det
	{
		var $oModule;
		var $oDatabase;
		var $aFields= array();
		var $aRow = array();
		var $cOptions	= DEFAULT_MAKE_DET;
		var $cTitle;
		var $cSummary ;
		var $nqCol ;
		var $cRowActions = "";
		var $cDetActions = "";

	function doc( $cMetodo, $cParametros )
	{
		ob_start();
		ob_clean();
		$this->$cMetodo($cParametros);
		$cReturn = ob_get_contents();
		ob_end_clean();
		return $cReturn ;
	}

	function addImage( $cUrlImage )
		{
			$this->cDetActions = "<img src='$cUrlImage '/><br/>" . $this->cDetActions  ;
		}
	function addDetAction( $cAction, $cParametros = '' , $cAccessKey = '', $ncModo = '', $cTarget = '')
		{
			$cActionHTML = $this->oModule->makeAction( '', $cAction, $cParametros , $ncModo , $cAccessKey , $cTarget);
			if ( $cActionHTML  ) $this->cDetActions .= '&nbsp;' . $cActionHTML ;
		}

	function getLevel ()
		{
			return $this->cOptions['0'];
		}
	function makeComplex()
		{
		}
	function setTitle ( $cTitle )
		{
			$this->cTitle = $cTitle;
		}
	function setOptions( $cOptions )
		{
			$this->cOptions = $cOptions;
		}
	function Det( &$oModule )
		{
			$this->oModule = &$oModule;
			$this->oDatabase = &$oModule->oDatabase;
		}
	function initialize()
	{
		return true;
	}
	function setColumns ( $nqColumns )
	{
		$this->nqCol = $nqColumns;
	}
	function make( $cOptions = ''  )
		{
			if ( $cOptions != '' ) $this->setOptions( $cOptions );
			if ( $this->initialize() == false ) return false;
			$this->initializeField($this->cOptions[2]);
			// Si no tiene definida la cantidad de columnas toma de acuerdo al modo
			if ( !$this->nqCol ) $this->nqCol 	= ( $this->cOptions[1] == 'V' ) ? 1: 2;
			?>
			<table class="detalle" summary="Esta tabla contiene <?= $this->cTitle; ?>">
				<? if ( $this->cOptions[1] == 'V' ) { ?>
					<caption><?= $this->cTitle; ?></caption>
				<? } ?>
				<tbody>
					<?
						$nIndex = 0;
						$nqRow = ceil(count($this->aFields ) / $this->nqCol);
						foreach ( $this->aFields as $cField => $cValue )
						{
							if ( ($nIndex % $this->nqCol ) == 0 ) echo "<tr>";
							if ( $cField ) echo "<th>$cField</th><td>$cValue</td>" ;
							else 					 echo "<td colspan='2'>$cValue</td>" ;
							$nIndex++;
							//Si hay acciones => Las Agrega en la ultima columna
							if ( $this->cDetActions &&  $nIndex == $this->nqCol  )
							{
								echo "<th nowrap valign='top' rowspan='$nqRow' >" . $this->cDetActions . "</th>";
							}
							if ( ($nIndex % $this->nqCol ) == 0 ) echo "</tr>";
						}
					?>
				</tbody>
				<? ?>
				</table>
			<?
			if ( $this->cOptions[0] == 'C' )
			{
				$this->makeComplex();
			}
		}
	function makeTit()
		{
			$this->make( DEFAULT_MAKE_TIT );
		}
	function makeDet()
		{
			$this->make( DEFAULT_MAKE_DET );
		}
	}
?>
